/**
 * 
 */
package com.rangers.auth.sample.jpa.entity;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

import com.rangers.auth.base.details.BriefRole;
import com.rangers.auth.sample.jpa.convert.SetMenuConverter;
import com.rangers.auth.sample.jpa.convert.SetScopeConverter;

import lombok.Data;

@Data
@Entity
@Table(name="tb_role")
public class Role implements BriefRole<Menu,Scope,Long>{
	@Id
	@GeneratedValue
	private Long id;
	
	@NotEmpty(message = "角色名称不能为空")
	@Length(max = 64, message = "角色名称位数必须在[64]位以内")
	private String name;// 角色名

	@Column(columnDefinition="blob",nullable=true)
	@Convert(converter = SetMenuConverter.class)
	private Set<Menu> menus;// 菜单

	@Convert(converter = SetScopeConverter.class)
	private Set<Scope> scopes;// 所属范围
}
